//
//  TWItemCollectionCell.swift
//  EyepetizerImitative
//
//  Created by 田伟 on 2017/3/10.
//  Copyright © 2017年 个人. All rights reserved.
//  集合视图分2部分：上面一个header，是一张图片，下面是横向的集合，里面都是完整的video,最后一个是查看全部

import UIKit
import SDWebImage

class TWItemCollectionCell: UITableViewCell {

    
    @IBOutlet weak var topBgImageView: UIImageView!
    @IBOutlet weak var detailCollectionView: TWDetailCollectionView!
    
    // MARK:- 自定义属性
    var itemCollectionModel : TWItemCollectionModel?{
        didSet {
            guard let itemCollectionModel = itemCollectionModel else {
                return
            }
            
            let urlString = itemCollectionModel.header?.cover
            guard let urlStr = urlString else {
                return
            }
            // 设置大图控件
            topBgImageView.sd_setImage(with: URL(string: urlStr))
            // 设置detailCollectionView的内容
            detailCollectionView.videosArray = itemCollectionModel.itemList_tw
        }
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
        let tap = UITapGestureRecognizer(target: self, action: #selector(topBgImageViewDidTap(tap:)))
        topBgImageView.addGestureRecognizer(tap)
    }
    
    @objc fileprivate func topBgImageViewDidTap(tap : UITapGestureRecognizer){
        print((itemCollectionModel?.header?.actionUrl)! as String)
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    
}
